import React from 'react'
import { View } from '@tarojs/components'
import { AtCard, AtAvatar } from "taro-ui"
import styles from './index.module.less'
import Icon from '../icon'
import Taro from '@tarojs/taro'
// import { request } from '../../utils/request'

// const thumbUpFunc = (id) => {
//   return request('PATCH', `/app/postbar/thump/${id}`, {})
// }

const BarkCard: React.FC<{
  Barks: any[],
  type: string
}> = ({ Barks, type }) => {
  const goDeatil = (id: number) => {
    Taro.navigateTo({
      url: `/pages/barkDetail/index?id=${id}`,
    })
    Taro.setNavigationBarTitle({
      title: type === 'bark' ? '帖子详情' : '招聘详情'
    })
  }
  // const thumbUp = (e, id) => {
  //   e.stopPropagation();
  //   console.log(id);
  //   thumbUpFunc(id).then((res) => {
  //     console.log(res);

  //   })
  // }
  return (
    <View className={styles.barkCard}>
      {Barks && Barks.map(item => {
        return (
          <AtCard
            onClick={() => goDeatil(item.id)}
            className={styles.card}
            title={item.nickName || '匿名用户'}
            // isFull
            renderIcon={
              <View className={styles.imges}>
                <AtAvatar size="small" circle image={item.avatarUrl}></AtAvatar>
              </View>
            }
          >
            <View>{item.content}</View>
            <View className={styles.footer}>
              <View><Icon classTitle="icon iconfont icon-ai-eye"></Icon> {item.lookNum}</View>
              {/* <View onClick={(e) => thumbUp(e, item.id)} ><Icon classTitle="icon iconfont icon-tubiaozhizuo-"></Icon> {item.thumbUp}</View> */}
              <View><Icon classTitle="icon iconfont icon-tubiaozhizuo-1"></Icon> {item.commentNum}</View>
            </View>
          </AtCard>
        )
      })
      }
    </View>

  )
}

export default BarkCard
